﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace BPM.Web.Shared.Data;

/// <summary>
/// 通知公告表
/// 融合了NoticeDetailOutput
/// </summary>
public partial class SysNotice : BaseVM
{
    /// <summary>
    /// 主键Id
    /// </summary>
    [DisplayName("业务号")]
    [Required(ErrorMessage = "业务号不能为空")]
    [JsonPropertyName("id")]
    public long Id { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [DisplayName("创建时间")]
    [JsonPropertyName("createdTime")]
    public System.DateTimeOffset? CreatedTime { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    [DisplayName("更新时间")]
    [JsonPropertyName("updatedTime")]
    public System.DateTimeOffset? UpdatedTime { get; set; }

    /// <summary>
    /// 创建者Id
    /// </summary>
    [DisplayName("创建者Id")]
    [JsonPropertyName("createdUserId")]
    public long? CreatedUserId { get; set; }

    /// <summary>
    /// 创建者名称
    /// </summary>
    [DisplayName("创建者名称")]
    [JsonPropertyName("createdUserName")]
    [StringLength(20)]
    public string? CreatedUserName { get; set; }

    /// <summary>
    /// 修改者Id
    /// </summary>
    [DisplayName("修改者Id")]
    [JsonPropertyName("updatedUserId")]
    public long? UpdatedUserId { get; set; }

    /// <summary>
    /// 修改者名称
    /// </summary>
    [DisplayName("修改者名称")]
    [JsonPropertyName("updatedUserName")]
    [StringLength(20)]
    public string? UpdatedUserName { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    [DisplayName("标题")]
    [JsonPropertyName("title")]
    [Required(ErrorMessage = "标题不能为空")]
    [StringLength(20)]
    public string? Title { get; set; }

    /// <summary>
    /// 内容
    /// </summary>
    [DisplayName("内容")]
    [JsonPropertyName("content")]
    [Required(ErrorMessage = "内容不能为空")]
    public string? Content { get; set; }

    /// <summary>
    /// 类型（字典 1通知 2公告）
    /// </summary>
    [DisplayName("类型")]
    [JsonPropertyName("type")]
    [Required(ErrorMessage = "类型不能为空")]
    public NoticeType Type { get; set; } = NoticeType.NOTICE;

    /// <summary>
    /// 发布人Id
    /// </summary>
    [DisplayName("发布人Id")]
    [JsonPropertyName("publicUserId")]
    public long PublicUserId { get; set; }

    /// <summary>
    /// 发布人姓名
    /// </summary>
    [DisplayName("发布人姓名")]
    [JsonPropertyName("publicUserName")]
    [StringLength(20)]
    public string? PublicUserName { get; set; }

    /// <summary>
    /// 发布机构Id
    /// </summary>
    [DisplayName("发布机构Id")]
    [JsonPropertyName("publicOrgId")]
    public long PublicOrgId { get; set; }

    /// <summary>
    /// 发布机构名称
    /// </summary>
    [DisplayName("发布机构名称")]
    [JsonPropertyName("publicOrgName")]
    [StringLength(50)]
    public string? PublicOrgName { get; set; }

    /// <summary>
    /// 发布时间
    /// </summary>
    [DisplayName("发布时间")]
    [JsonPropertyName("publicTime")]
    public System.DateTimeOffset? PublicTime { get; set; }

    /// <summary>
    /// 撤回时间
    /// </summary>
    [DisplayName("撤回时间")]
    [JsonPropertyName("cancelTime")]
    public System.DateTimeOffset? CancelTime { get; set; }

    [DisplayName("状态")]
    [JsonPropertyName("status")]
    public NoticeStatus Status { get; set; }

    [DisplayName("关键词")]
    [JsonIgnore]
    public string? SearchValue { get; set; }

    [JsonIgnore]
    [DisplayName("通知到的人")]
    [Required(ErrorMessage = "必须选择要通知的人")]
    public string? NoticeUserIds
    {
        get => string.Join(',', NoticeUserIdList);
        set => NoticeUserIdList = value?.Split(',') ?? Enumerable.Empty<string>();
    }

    /// <summary>
    /// 通知到的用户Id集合
    /// </summary>
    [JsonIgnore]
    public IEnumerable<string> NoticeUserIdList { get; set; } = Enumerable.Empty<string>();

    /// <summary>
    /// 通知到的用户阅读信息集合
    /// </summary>
    [JsonIgnore]
    public IEnumerable<NoticeUserRead> NoticeUserReadInfoList { get; set; } = Enumerable.Empty<NoticeUserRead>();

    [JsonPropertyName("readStatus")]
    public NoticeUserStatus ReadStatus { get; set; }

    /// <summary>
    /// 阅读时间
    /// </summary>
    [DisplayName("阅读时间")]
    [JsonPropertyName("readTime")]
    public System.DateTimeOffset? ReadTime { get; set; }
}
